<?php

App::uses('Controller', 'Controller');

/**
 * Class AppController
 */
class AppController extends Controller {

	protected $filter = array('logins');

	public $components = array(
		'DebugKit.Toolbar',
		'Session',
	);

	public $helpers = ['Html'];

	public function beforeFilter() {

		if (in_array(strtolower($this->name), $this->filter)) {
			return null;
		}
		$this->layout = 'home';
		$this->ext = '.html';
		parent::beforeFilter();
	}

	public function isAjax() {
		if (!$this->request->is('ajax')) {
			throw new MethodNotAllowedException();
		}
		$this->autoLayout = $this->autoRender = false;
	}

	public function loadFrame() {
		$this->layout = 'frame';
		$this->ext = '.html';
	}

	public function success($info, $url = '') {
		die(json_encode(array('status' => true, 'info' => $info, 'url' => $url)));
	}

	public function error($info, $url = '') {
		die(json_encode(array('status' => false, 'info' => $info, 'url' => $url)));
	}
}
